import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
import { EntityBase } from "@/common/entities/entity.base";
import { User } from "@/modules/user/entities/user.entity";


@Entity()
export class UserSubuser extends EntityBase {
    @PrimaryGeneratedColumn()
    id: number;
    
    @Column("int")
    userId: number;
    
    @Column("int")
    subuserId: number;
    
    @ManyToOne(() => User, (user) => user.id, { onDelete: "CASCADE" })
        // @JoinColumn({ name: 'userId' }) // 设置列名为'userId'，与TypeORM自动生成的列名相同
    user: User;
    
    @ManyToOne(() => User, (user) => user.id, { onDelete: "CASCADE" })
        // @JoinColumn({ name: 'userId' }) // 设置列名为'userId'，与TypeORM自动生成的列名相同
    subuser: User;
}
